﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FrmHotel
{
    public partial class FrmAddLieXing : Form
    {
        public FrmAddLieXing()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            string name = this.textBox1.Text;
            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("请填写商品类型名称！！", "提示信息！");
                return;
            }
            string sql1 = string.Format("select count(1) from CommodityClass where ClassName='{0}'",name);
            int r = Convert.ToInt32(DBHelper.SelectOne(sql1));
            if(r>=1)
            {
                MessageBox.Show("此类型名称已存在，请勿重复添加！", "提示信息！");
                return;
            }
            string sql = string.Format(@"insert into CommodityClass values('{0}')", name);
            int Z1 = Convert.ToInt32(DBHelper.ExecuteUpdate(sql));
            if (Z1 > 0 )
            {
                MessageBox.Show("添加成功！", "提示信息！");
            }
            else
            {
                MessageBox.Show("添加失败！", "提示信息！");
                return;
            }
        }
    }
}
